package com.changgou.page.listener;

import com.changgou.page.config.RabbitMQConfig;
import com.changgou.page.service.PageService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author kfzhao
 * @version 1.0
 * @className PageListener
 * @description
 * @date 2021/12/31 1:29
 */
@Component
public class PageListener {

    @Autowired
    private PageService pageService;

    @RabbitListener(queues = {RabbitMQConfig.PAGE_CREATE_QUEUE})
    public void receiveMessage(String spuId) {
        System.out.println("获取静态化页面的商品id：" + spuId);
        // 调用业务层完成静态化页面的生成
        pageService.generateHtml(spuId);
    }
}
